﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;

namespace TestF_AutoMapper
{
    class Program
    {

        static void Main(string[] args)
        {

            DTOObject _result;
            IDataReader _dataReader;
            Mapper.Initialize(cfg =>
            {
                cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
                cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
                cfg.CreateMap<IDataReader, IEnumerable<DTOObject>>();
            });

            _dataReader = new DataBuilder().BuildDataReader();
            _result = Mapper.Map<IDataReader, IEnumerable<DTOObject>>(_dataReader).FirstOrDefault();
            Console.ReadLine();
        }
    }

    public class DataBuilder
    {
        public IDataReader BuildDataReader()
        {
            var resultData = new DataTable();
            resultData.Columns.Add(FieldName.PhoneNumber, typeof(string));
            resultData.Columns.Add(

            var resultDataRow = resultData.NewRow();
            resultDataRow[FieldName.PhoneNumber] = "111-222-3333";
            resultDataRow[FieldName.Name] = "dfsfsdfsdfsdfsdfsd";
            resultData.Rows.Add(resultDataRow);

            return resultData.CreateDataReader();
        }
    }

    internal class FieldName
    {
        public const String Id = "id";
        public const String Name = "name";
        public const String PhoneNumber = "phone_number";
        public const String CreateDate = "create_date";
    }

    public class DTOObject
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public string PhoneNumber { get; set; }
        public DateTime CreatedDate { get; set; }
    }

}
